package com.bjtu.lms.action.user;

import com.bjtu.lms.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 
 * @author yilee
 */
public class AddUserAction extends ActionSupport {

	private String name;
	private UserService userService;
	private String username;
	private String password;
	private String phone;
	private String email;

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Override
	public String execute() throws Exception {
		if (name == null || name.equals("") || username == null
				|| username.equals("") || password == null
				|| password.equals("") || email == null || email.equals("")) {
			return SUCCESS;
		}
		userService.addUser(name, username, password, phone, email);
		return SUCCESS;
	}
}
